/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.cip.esymons.eventos.bc;

import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.naming.NamingException;
import org.cip.esymons.eventos.be.EnvioTramite;

/**
 *
 * @author oscar
 */
public class ConfigurarTramiteDelegate {

    EnvioTramiteFacadeLocal local;

    public ConfigurarTramiteDelegate() {
        local = lookupEnvioTramiteFacade();
    }

    private EnvioTramiteFacadeLocal lookupEnvioTramiteFacade() {
        try {
            Context c = new InitialContext();
            return (EnvioTramiteFacadeLocal) c.lookup("java:comp/env/EnvioTramiteFacade");
        } catch (NamingException ne) {
            Logger.getLogger(getClass().getName()).log(Level.SEVERE, "exception caught", ne);
            throw new RuntimeException(ne);
        }
    }

    public List<EnvioTramite> listaTramite() {
        return local.findAll();
    }

    public void registrar(EnvioTramite tra){
        local.create(tra);
    }

    public void actualizar(EnvioTramite tra){
        local.edit(tra);
    }

    public EnvioTramite buscar(Integer id){
        return local.find(id);
    }

    public void eliminar(EnvioTramite tra){
        local.remove(tra);
    }

}
